package com.glodon.paas.monitor.server.biz.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorItemAlarmRulesEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorItemAlarmRulesMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorItemAlarmRulesService;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorItemAlarmRulesService")
public class MonitorItemAlarmRulesServiceImpl implements MonitorItemAlarmRulesService {

	@Autowired
	private MonitorItemAlarmRulesMapper	monitorItemAlarmRulesMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey itemAlarmRules id is null!");
		}
		return monitorItemAlarmRulesMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorItemAlarmRulesEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insert itemAlarmRules record is null!");
		}
		return monitorItemAlarmRulesMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorItemAlarmRulesEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insertSelective itemAlarmRules record is null!");
		}
		return monitorItemAlarmRulesMapper.insertSelective(record);
	}

	@Override
	public MonitorItemAlarmRulesEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey itemAlarmRules id is null!");
		}
		return monitorItemAlarmRulesMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorItemAlarmRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective itemAlarmRules record is null!");
		}
		return monitorItemAlarmRulesMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorItemAlarmRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey itemAlarmRules record is null!");
		}
		return monitorItemAlarmRulesMapper.updateByPrimaryKey(record);
	}

	@Override
	public MonitorItemAlarmRulesEntity selectByItemId(Long itemId) {
		if (null == itemId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByItemId itemAlarmRules itemId is null!");
		}
		return monitorItemAlarmRulesMapper.selectByItemId(itemId);
	}

	@Override
	public MonitorItemAlarmRulesEntity selectByAlarmId(Long alarmId) {
		if (null == alarmId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByAlarmId itemAlarmRules alarmId is null!");
		}
		return monitorItemAlarmRulesMapper.selectByAlarmId(alarmId);
	}
}
